﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace Billing2
{
    public class ClsBooking
    {
        private int _IsNew = 1;
        public int IsNew
        {
            get
            {
                return _IsNew;
            }
            set
            {
                _IsNew = value;
            }
        }

        private long _ID = 0;
        public long ID
        {
            get
            {
                return _ID;
            }
            set
            {
                _ID = value;
            }
        }

        private string _BookingUniqueID = "";
        public string BookingUniqueID
        {
            get
            {
                return _BookingUniqueID;
            }
            set
            {
                _BookingUniqueID = value;
            }
        }

        private DateTime _BookingDate = DateTime.Now;
        public DateTime BookingDate
        {
            get
            {
                return _BookingDate;
            }
            set
            {
                _BookingDate = value;
            }
        }

        private string _BeginTimeSlot = "";
        public string BeginTimeSlot
        {
            get
            {
                return _BeginTimeSlot;
            }
            set
            {
                _BeginTimeSlot = value;
            }
        }

        private string _EndTimeSlot = "";
        public string EndTimeSlot
        {
            get
            {
                return _EndTimeSlot;
            }
            set
            {
                _EndTimeSlot = value;
            }
        }

        private int _SerialNo = 0;
        public int SerialNo
        {
            get
            {
                return _SerialNo;
            }
            set
            {
                _SerialNo = value;
            }
        }

        private int _NewCardCount = 0;
        public int NewCardCount
        {
            get
            {
                return _NewCardCount;
            }
            set
            {
                _NewCardCount = value;
            }
        }

        private int _ReplaceCardCount = 0;
        public int ReplaceCardCount
        {
            get
            {
                return _ReplaceCardCount;
            }
            set
            {
                _ReplaceCardCount = value;
            }
        }

        private int _RepersonalizeCardCount = 0;
        public int RepersonalizeCardCount
        {
            get
            {
                return _RepersonalizeCardCount;
            }
            set
            {
                _RepersonalizeCardCount = value;
            }
        }

        private int _TerminateCardCount = 0;
        public int TerminateCardCount
        {
            get
            {
                return _TerminateCardCount;
            }
            set
            {
                _TerminateCardCount = value;
            }
        }

        private int _Type3CardCount = 0;
        public int Type3CardCount
        {
            get
            {
                return _Type3CardCount;
            }
            set
            {
                _Type3CardCount = value;
            }
        }

        private int _NewCardCountConfirm = 0;
        public int NewCardCountConfirm
        {
            get
            {
                return _NewCardCountConfirm;
            }
            set
            {
                _NewCardCountConfirm = value;
            }
        }

        private int _ReplaceCardCountConfirm = 0;
        public int ReplaceCardCountConfirm
        {
            get
            {
                return _ReplaceCardCountConfirm;
            }
            set
            {
                _ReplaceCardCountConfirm = value;
            }
        }

        private int _RepersonalizeCardCountConfirm = 0;
        public int RepersonalizeCardCountConfirm
        {
            get
            {
                return _RepersonalizeCardCountConfirm;
            }
            set
            {
                _RepersonalizeCardCountConfirm = value;
            }
        }

        private int _TerminateCardCountConfirm = 0;
        public int TerminateCardCountConfirm
        {
            get
            {
                return _TerminateCardCountConfirm;
            }
            set
            {
                _TerminateCardCountConfirm = value;
            }
        }

        private int _Type3CardCountConfirm = 0;
        public int Type3CardCountConfirm
        {
            get
            {
                return _Type3CardCountConfirm;
            }
            set
            {
                _Type3CardCountConfirm = value;
            }
        }

        private long _BookingStatus = 0;
        public long BookingStatus
        {
            get
            {
                return _BookingStatus;
            }
            set
            {
                _BookingStatus = value;
            }
        }

        private string _Remarks = "";
        public string Remarks
        {
            get
            {
                return _Remarks;
            }
            set
            {
                _Remarks = value;
            }
        }

        private long _CreatedBy = 0;
        public long CreatedBy
        {
            get
            {
                return _CreatedBy;
            }
            set
            {
                _CreatedBy = value;
            }
        }

        private string _CreatedName = "";
        public string CreatedName
        {
            get
            {
                return _CreatedName;
            }
            set
            {
                _CreatedName = value;
            }
        }

        private string _SiteName = "";
        public string SiteName
        {
            get
            {
                return _SiteName;
            }
            set
            {
                _SiteName = value;
            }
        }

        private string _OrgName = "";
        public string OrgName
        {
            get
            {
                return _OrgName;
            }
            set
            {
                _OrgName = value;
            }
        }

        private DateTime _CreatedDatetime = DateTime.Now;
        public DateTime CreatedDatetime
        {
            get
            {
                return _CreatedDatetime;
            }
            set
            {
                _CreatedDatetime = value;
            }
        }

        private long _CancelleddBy = 0;
        public long CancelleddBy
        {
            get
            {
                return _CancelleddBy;
            }
            set
            {
                _CancelleddBy = value;
            }
        }

        private DateTime _CancelledDatetime = DateTime.Now;
        public DateTime CancelledDatetime
        {
            get
            {
                return _CancelledDatetime;
            }
            set
            {
                _CancelledDatetime = value;
            }
        }

        private long _SubmittedBy = 0;
        public long SubmittedBy
        {
            get
            {
                return _SubmittedBy;
            }
            set
            {
                _SubmittedBy = value;
            }
        }

        private DateTime _SubmittedDatetime = DateTime.Now;
        public DateTime SubmittedDatetime
        {
            get
            {
                return _SubmittedDatetime;
            }
            set
            {
                _SubmittedDatetime = value;
            }
        }

        private long _RejectedBy = 0;
        public long RejectedBy
        {
            get
            {
                return _RejectedBy;
            }
            set
            {
                _RejectedBy = value;
            }
        }

        private DateTime _RejectedDatetime = DateTime.Now;
        public DateTime RejectedDatetime
        {
            get
            {
                return _RejectedDatetime;
            }
            set
            {
                _RejectedDatetime = value;
            }
        }

        private long _AckBy = 0;
        public long AckBy
        {
            get
            {
                return _AckBy;
            }
            set
            {
                _AckBy = value;
            }
        }

        private DateTime _AckDatetime = DateTime.Now;
        public DateTime AckDatetime
        {
            get
            {
                return _AckDatetime;
            }
            set
            {
                _AckDatetime = value;
            }
        }

        private long _ClosedBy = 0;
        public long ClosedBy
        {
            get
            {
                return _ClosedBy;
            }
            set
            {
                _ClosedBy = value;
            }
        }

        private DateTime _ClosedDatetime = DateTime.Now;
        public DateTime ClosedDatetime
        {
            get
            {
                return _ClosedDatetime;
            }
            set
            {
                _ClosedDatetime = value;
            }
        }

        public static DataTable BookingSuggest(DateTime BookingDate, int NewCard, int ReplaceCard, int RepersonalizeCard, int TerminateCard, int Type3Card)
        {
            DataTable rtn = null;
            DBLibrary.DBProcedures.Sp_Booking_SelectSuggestInformationByBookingDate(BookingDate, NewCard, ReplaceCard, RepersonalizeCard, TerminateCard, Type3Card, ref rtn);
            return rtn;
        }
        public static int GetFreeResource(DateTime BookingDate, ref int FreeResource, ref int FreeResourceT3, ref int result, ref string msg)
        {
            return DBLibrary.DBProcedures.Sp_Booking_GetFreeResourceByBookingDate(BookingDate, ref FreeResource, ref FreeResourceT3, ref result, ref msg);
        }

        public static int GetEndTimeSlot(DateTime BookingDate, string BeginTime, int NewCard, int ReplaceCard, int RepersonalizeCard, int TerminateCard, int Type3Card,ref int EndTimeSlotID, ref string EndTime)
        {
            int result = 0;
            string msg = "";
            DBLibrary.DBProcedures.Sp_Booking_GetEndTimeSlotByBeginTimeSlot(BookingDate, BeginTime, NewCard, ReplaceCard, RepersonalizeCard, TerminateCard, Type3Card, ref EndTimeSlotID, ref EndTime, ref result, ref msg);
            return result;
        }

        public static int Submit(DateTime BookingDate, string BeginTimeSlot, int NewCard, int ReplaceCard, int RepersonalizeCard, int TerminateCard, int Type3Card, long UserID, string Remarks, ref Int64 BookingID, ref string BookingUniqueID, ref string EndTimeSlot, ref int Result, ref string ErrorMsg)
        {
            return DBLibrary.DBProcedures.Sp_Booking_Submit(BookingDate, BeginTimeSlot, NewCard, ReplaceCard, RepersonalizeCard, TerminateCard, Type3Card, UserID, Remarks, ref BookingID, ref BookingUniqueID, ref EndTimeSlot, ref Result, ref ErrorMsg);
        }

        public static DataTable SelectByStatus(long status,long siteid)
        {
            DataTable rtn = null;
            DBLibrary.DBProcedures.Sp_Booking_SelectbyStatus(status, siteid, ref rtn);
            return rtn;
        }

        public static DataTable SelecDetailByBookingID(long bookingid)
        {
            DataTable rtn = null;
            DBLibrary.DBProcedures.Sp_BookingDetailsSelectByBookingID(bookingid, ref rtn);
            return rtn;
        }

        public static DataTable SelecTimeSlotByBookingDate(DateTime BookingDate)
        {
            DataTable rtn = null;
            DBLibrary.DBProcedures.Sp_Booking_SelectTimeSlotByBookingDate(BookingDate, ref rtn);
            return rtn;
        }

        public int Load(ref string ErrorMessage)
        {
            int rtn = 0;
            ErrorMessage = "Successfully!";
            DBLibrary.DBProcedures.Sp_Booking_Locate(_ID, ref _BookingUniqueID, ref _BookingDate, ref _BeginTimeSlot, ref _EndTimeSlot, ref _SerialNo, ref _NewCardCount, ref _ReplaceCardCount, ref _RepersonalizeCardCount, ref _TerminateCardCount, ref _Type3CardCount, ref _NewCardCountConfirm, ref _ReplaceCardCountConfirm, ref _RepersonalizeCardCountConfirm, ref _TerminateCardCountConfirm, ref _Type3CardCountConfirm, ref _BookingStatus, ref _Remarks, ref _CreatedBy, ref _CreatedName, ref _SiteName, ref _OrgName, ref _CreatedDatetime, ref _CancelleddBy, ref _CancelledDatetime, ref _SubmittedBy, ref _SubmittedDatetime, ref _RejectedBy, ref _RejectedDatetime, ref _AckBy, ref _AckDatetime, ref _ClosedBy, ref _ClosedDatetime, ref rtn, ref ErrorMessage);
            return rtn;
        }

        public int LoadByBookingUniqueID(ref string ErrorMessage)
        {
            int rtn = 0;
            ErrorMessage = "Successfully!";
            DBLibrary.DBProcedures.Sp_Booking_LocateByBookingUniqueID(ref _ID, _BookingUniqueID, ref _BookingDate, ref _BeginTimeSlot, ref _EndTimeSlot, ref _SerialNo, ref _NewCardCount, ref _ReplaceCardCount, ref _RepersonalizeCardCount, ref _TerminateCardCount, ref _Type3CardCount, ref _NewCardCountConfirm, ref _ReplaceCardCountConfirm, ref _RepersonalizeCardCountConfirm, ref _TerminateCardCountConfirm, ref _Type3CardCountConfirm, ref _BookingStatus, ref _Remarks, ref _CreatedBy, ref _CreatedName, ref _SiteName, ref _OrgName, ref _CreatedDatetime, ref _CancelleddBy, ref _CancelledDatetime, ref _SubmittedBy, ref _SubmittedDatetime, ref _RejectedBy, ref _RejectedDatetime, ref _AckBy, ref _AckDatetime, ref _ClosedBy, ref _ClosedDatetime, ref rtn, ref ErrorMessage);
            return rtn;
        }

        public static int Cancel(long BookingID, long CancelledBy, ref int Result, ref string ErrorMsg)
        {
            return DBLibrary.DBProcedures.Sp_Booking_Cancel(BookingID, CancelledBy, ref Result, ref ErrorMsg);
        }

        public static int Acknowledge(long BookingID, long AcknowledgedBy, ref int Result, ref string ErrorMsg)
        {
            return DBLibrary.DBProcedures.Sp_Booking_Acknowledge(BookingID, AcknowledgedBy, ref Result, ref ErrorMsg);
        }

        public static int Reject(long BookingID, long RejectedBy, string Remarks, ref int Result, ref string ErrorMsg)
        {
            return DBLibrary.DBProcedures.Sp_Booking_Reject(BookingID, RejectedBy, Remarks, ref Result, ref ErrorMsg);
        }

        public static int Close(long BookingID, int NewCardCountConfirm, int ReplaceCardCountConfirm, int RepersonalizeCardCountConfirm, int TerminateCardCountConfirm, int Type3CardCountConfirm, string Remarks, long ClosedBy, ref int Result, ref string ErrorMsg)
        {
            return DBLibrary.DBProcedures.Sp_Booking_Close(BookingID, NewCardCountConfirm,ReplaceCardCountConfirm,RepersonalizeCardCountConfirm,TerminateCardCountConfirm,Type3CardCountConfirm,Remarks,ClosedBy, ref Result, ref ErrorMsg);
        }
    }
}